package dlally.controller;

import dlally.model.DecisionLinesEvent;
import dlally.view.GameFieldGUI;
import junit.framework.TestCase;
/**
 * Tests the construction and all the methods in the ChoiceController
 * @author Douglas Lally (dlally@wpi.edu)
 *
 */
public class testChoiceController extends TestCase {
	
	/**
	 * This will need a model, gui, and 3 controllers, since each controller only operates on one line
	 */
	DecisionLinesEvent model;
	GameFieldGUI gui;
	ChoiceController cController0;
	ChoiceController cController1;
	ChoiceController cController2;

	/**
	 * Set up the model, gui, and controllers
	 */
	protected void setUp() throws Exception {
		super.setUp();
		model = new DecisionLinesEvent(3,3);
		gui = new GameFieldGUI(model);
		cController0 = new ChoiceController(gui,model,0);
		cController1 = new ChoiceController(gui,model,1);
		cController2 = new ChoiceController(gui,model,2);
		
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	/**
	 * Throughly test the process() method, which also implicitly tests the allNamed method
	 */
	public void testProcess(){
		assertEquals(model.getLines()[0].getChoice(), "");
		assertEquals(model.getLines()[1].getChoice(), "");
		assertEquals(model.getLines()[2].getChoice(), "");
		gui.getChoice(0).setText("");
		gui.getChoice(1).setText("testName1");
		gui.getChoice(2).setText("testName2");
		cController0.process();
		cController1.process();
		cController2.process();
		gui.getChoice(0).setText("testName0");
		cController0.process();
		assertEquals(model.getLines()[0].getChoice(), "testName0");
		assertEquals(model.getLines()[1].getChoice(), "testName1");
		assertEquals(model.getLines()[2].getChoice(), "testName2");
	}

}
